﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace IODataAccess
{
    public static class clsDAStaticMethod
    {

        public static int getIDIdentity(string table)
        {
            clsDAConnection con = new clsDAConnection();
            try
            {
                string str = "select Max(id) as ID from " + table;
                SqlCommand com = new SqlCommand(str, con.getCon());
                con.openCon();
                int id = 0;
                SqlDataReader dr = com.ExecuteReader();
                if (dr.Read())
                {
                    if (dr["ID"]!=DBNull.Value)
                    id = Convert.ToInt32(dr["ID"]);
                }
                return id;
            }
            catch (Exception)
            {

                throw;
            }
            finally
            {
                con.closeCon();
            }
        }
    }
}
